package com.woniu.user.mapper;

import com.woniu.user.entity.Complain;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author author
 * @create 2021/5/19
 * <p>
 * 投诉映射接口
 */
@Mapper
public interface ComplainMapper {
    //新增投诉
    @Insert("insert into complain values(default,#{type},#{photo},#{address},#{content},#{cdate},#{u_id},1)")
    Boolean addComplain(Complain complain);

    //修改状态
    @Update("update complain set status = 2 where id = #{id}")
    Boolean updateStatusById(Integer id);

    //查询所有投诉
    @Select("<script> select * from complain " +
            "<if test=\"status != 0\">" +
            "where status = #{status}" +
            "</if></script>")
    List<Complain> selectAllComplain(Integer status);


}
